/**
 * 
 */
package com.hand.cloud.b2b.daos.impl;

import de.hybris.platform.servicelayer.ServicelayerTransactionalTest;

import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.annotation.Resource;

import junit.framework.Assert;

import org.junit.Test;

import com.hand.cloud.b2b.daos.TBTradeDAO;
import com.hand.cloud.b2b.model.TB_TradeModel;
import com.taobao.api.domain.Order;
import com.taobao.api.domain.Trade;


/**
 * @author Snowling
 * 
 */
public class DefaultTBTradeDAOTest extends ServicelayerTransactionalTest
{
	@Resource
	private TBTradeDAO tbTradeDAO;

	@Test
	public void testTBTrade()
	{
		final Trade trade = new Trade();
		final Order order = new Order();
		final List<Order> orders = new ArrayList<Order>();

		trade.setBuyerAlipayNo("tbtest1063");
		final SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		final ParsePosition pos = new ParsePosition(0);
		final Date date = formatter.parse("2000-01-01 00:00:00", pos);
		trade.setCreated(date);
		trade.setDiscountFee("200.07");
		trade.setHasPostFee(true);
		trade.setInvoiceName("淘宝");
		trade.setInvoiceType("水果");
		trade.setPayment("200");
		trade.setPointFee((long) 0);
		trade.setPostFee("15");
		trade.setSellerCodFee("12.07");
		trade.setSnapshotUrl("T1mURbXopZXXXe3rL");
		trade.setStatus("TRADE_NO_CREATE_PAY");
		trade.setTotalFee("290");
		trade.setType("fixed");

		order.setNum((long) 30);
		order.setPrice("200.07");
		order.setItemMealName("M8原装电池");
		orders.add(order);
		trade.setOrders(orders);
		final TB_TradeModel tbTrade = tbTradeDAO.createTBTrade(trade);
		Assert.assertNotNull(tbTrade.getPk());
		Assert.assertNotNull(tbTrade);
	}
}
